﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WebeTerm.PlugIns;

namespace WebeTerm.RobotBook
{
    /// <summary>
    /// 自动订位结果模板
    /// </summary>
    public sealed class RobotBookResult : BasePlugInResult
    {
        /// <summary>
        /// 订座结果
        /// </summary>
        public RequireBook RobotRequire { get; set; }

        public override string ToDisplay()
        {
            if (this.RobotRequire != null)
            {
                if (string.IsNullOrEmpty(this.RobotRequire.PNRNO))
                {
                    return string.Format(@"{0}-{1}({2})[{3}]<{4}>", this.RobotRequire.Dept, this.RobotRequire.Dest, this.RobotRequire.DeptDate, this.RobotRequire.AirWay, string.Join(",", this.RobotRequire.AvResultItem.ToArray()));
                }
                else if (!string.IsNullOrEmpty(this.RobotRequire.Code))
                {
                    return string.Format(@"{0}-{1}({2})[{3}]<{4}> 大编号:{5} PNR:{6}", this.RobotRequire.Dept, this.RobotRequire.Dest, this.RobotRequire.DeptDate, this.RobotRequire.AirWay, string.Join(",", this.RobotRequire.AvResultItem.ToArray()), this.RobotRequire.Code,this.RobotRequire.PNRNO);
                }
                else {
                    return string.Format(@"{0}-{1}({2})[{3}]<{4}> PNR:{5}", this.RobotRequire.Dept, this.RobotRequire.Dest, this.RobotRequire.DeptDate, this.RobotRequire.AirWay, string.Join(",", this.RobotRequire.AvResultItem.ToArray()), this.RobotRequire.PNRNO);
                }
            }
            else {
                return base.ToDisplay();
            }
        }
    }


    /// <summary>
    /// 自动订位配置模板.
    /// </summary>
    public sealed class RobotBookConfig : BasePlugInConfig
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="RobotBookConfig"/> class.
        /// </summary>
        public RobotBookConfig() {
            Requires = new List<RequireBook>();
            CabinChars = new List<CabinChar>();
        }

        /// <summary>
        /// 订票需求列表
        /// </summary>
        public List<RequireBook> Requires { get; set; }


        public List<CabinChar> CabinChars { get; set; }
    }

    /// <summary>
    /// 订票需求
    /// </summary>
    public sealed class RequireBook {

        public RequireBook() {
            Passengers = new List<Passenger>();
            AvResultItem = new List<string>();
        }
        public Guid Key { get; set; }

        public string Dept { get; set; }

        public string Dest { get; set; }

        public string AirWay { get; set; }

        public string DeptDate { get; set; }

        public string RetDate { get; set; }

        public List<Passenger> Passengers { get; set; }

        /// <summary>
        /// 有效航班SS订座指令
        /// </summary>
        public List<string> AvResultItem { get; set; }

        /// <summary>
        /// 订座PNR
        /// </summary>
        public string PNRNO { get; set; }

        /// <summary>
        /// 大记录编号
        /// </summary>
        public string Code { get; set; }

        /// <summary>
        /// 是否已查询完成
        /// </summary>
        public bool IsCompleted { get; set; }

    }

    public sealed class Passenger {
        public string Name { get; set; }

        public string IdNo { get; set; }

        public string Mobile { get; set; }
    }

    /// <summary>
    /// 订票舱位排列
    /// </summary>
    public sealed class CabinChar {
        public string AirWay { get; set; }

        public string CabinCharCode { get; set; }

        public int Weight { get; set; }
    }
}
